﻿using Abp.AutoMapper;
using Abp.Modules;
using System.Linq;
using Teleware.Newbe.Navigation.Web.AppServices;
using Teleware.Newbe.Navigation.Web.Domain.Entities;

namespace Teleware.Newbe.Navigation.Web.Modules
{
    [DependsOn(
        typeof(AbpAutoMapperModule))]
    public class NewbeAutoMapperModule : AbpModule
    {
        public override void PreInitialize()
        {
            Configuration.Modules.AbpAutoMapper().Configurators.Add(config =>
            {
                config.CreateMap<HrefInfo, SimpleHrefInfo>()
                    .ForMember(a => a.Tags, b => b.MapFrom(c => c.HrefInfoTags.Select(a => a.InfoTag.Text)))
                    .ForMember(a => a.Name, b => b.MapFrom(c => c.Name))
                    .ForMember(a => a.Remark, b => b.MapFrom(c => c.Remark))
                    .ForMember(a => a.Href, b => b.MapFrom(c => c.Href))
                    .ForMember(a => a.DepartmentId, b => b.MapFrom(c => c.Department.Id))
                    .ForMember(a => a.DepartmentName, b => b.MapFrom(c => c.Department.Name));

            });
        }
    }
}
